package com.shilan.administrator.qintfm.fragment.tablayoutFragment;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.android.volley.toolbox.ImageLoader;
import com.android.volley.toolbox.NetworkImageView;
import com.shilan.administrator.qintfm.R;
import com.shilan.administrator.qintfm.beans.RecommendResult;
import com.shilan.administrator.qintfm.fragment.BaseFragment;
import com.shilan.administrator.qintfm.volley.VolleySingleton;

import java.util.List;

/**
 * Created by dllo on 16/1/21.
 */
public class RecommendViewPageFragment extends BaseFragment{

    private NetworkImageView netIvRecViewPager;
    private ImageLoader imageLoader;
    private View view;
    private static List<RecommendResult.FocusImagesEntity.ListEntity> lists;

    public static RecommendViewPageFragment getInstance
            (String imgUrl, int position,
             List<RecommendResult.FocusImagesEntity.ListEntity> list) {
        RecommendViewPageFragment recommentViewPagerFragment =
                new RecommendViewPageFragment();
        lists = list;
        // 参数传递
        Bundle bundle = new Bundle();
        bundle.putString("imgUrl", imgUrl);
        bundle.putInt("position", position);
        recommentViewPagerFragment.setArguments(bundle);
        return recommentViewPagerFragment;
    }

    @Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
       View view = inflater.inflate(R.layout.viewpager_recommend_fragment,null);
        return view;
    }

    @Override
    public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
        super.onViewCreated(view, savedInstanceState);
        this.view = view;

        netIvRecViewPager = (NetworkImageView) view.findViewById(R.id.netIv_viewPagaerRecomment);
        //netIvRecViewPager.setOnClickListener(this); 轮播图暂不添加点击事件
    }

    @Override
    public void onActivityCreated(@Nullable Bundle savedInstanceState) {
        super.onActivityCreated(savedInstanceState);
        initData();
    }

    private void initData() {
        imageLoader = VolleySingleton.getInstance()._getImageLoader();
        Bundle bundle = this.getArguments();
        if (bundle != null) {
            String url = bundle.getString("imgUrl");
            netIvRecViewPager.setImageUrl(url, imageLoader);
//

//
  }
    }
}

